package com.servlet.users;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.UsersDAO;
import com.entity.Users;

public class FindAllUsersServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		List<Users> users = null;

		UsersDAO usersDAO = new UsersDAO();

		users = usersDAO.findAll();
		request.setAttribute("users", users);
		request.getRequestDispatcher("/background/userslist.jsp").forward(
				request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
		List<Users> users = null;

		UsersDAO usersDAO = new UsersDAO();

		users = usersDAO.findAll();
		request.setAttribute("users", users);
		RequestDispatcher re=request.getRequestDispatcher("/background/userslist.jsp");
		re.forward(request, response);
	}

}
